// /*
//  * @Author: your name
//  * @Date: 2020-09-13 08:42:53
//  * @LastEditTime: 2020-09-13 08:44:16
//  * @LastEditors: Please set LastEditors
//  * @Description: In User Settings Edit
//  * @FilePath: \woniutaofang\lib\pages\house\house_page.dart
//  */
// import 'package:flutter/material.dart';
// import 'package:woniutaofang/pages/mine/components/sliver_page.dart';
// import 'package:woniutaofang/pages/mine/components/user_info.dart';
//
// class MinePage extends StatelessWidget {
//   const MinePage({Key key}) : super(key: key);
//
//   @override
//   Widget build(BuildContext context) {
//     List listone = [
//       {"name": "我的预约", "code": "id1"},
//       {"name": "看房报告", "code": "id2"},
//       {"name": "我的卡片", "code": "id3"},
//       {"name": "我的收藏", "code": "id4"},
//     ];
//     List listrtwo = [
//       {"name": "帮我找房", "code": "id1"},
//       {"name": "联系客服", "code": "id2"},
//       {"name": "关于我们", "code": "id3"},
//       {"name": "服务声明", "code": "id4"},
//     ];
//     return Scaffold(
//       appBar: AppBar(
//         title: Text('我的'),
//         backgroundColor: Colors.red,
//       ),
//       body: Container(
//         child: Column(
//           children: [
//             UserInfoPage(),
//             SliverPage(
//               title: '我的预约',
//               list: listone,
//             ),
//             SliverPage(
//               title: '我的工具',
//               list: listrtwo,
//             )
//           ],
//         ),
//       ),
//     );
//   }
// }

import 'package:flutter/material.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
import 'package:woniutaofang/components/ui/button.dart';
import 'package:woniutaofang/components/ui/image_load_view.dart';
import 'package:woniutaofang/pages/mine/mine_router.dart';
import 'package:woniutaofang/routers/fluro_navigator.dart';
import 'package:woniutaofang/utils/utils.dart';

class MinePage extends StatefulWidget {
  MinePage({Key key}) : super(key: key);

  @override
  createState() => _MinePageState();
}

class _MinePageState extends State<MinePage> {
  double bannerHeight, radius, padding;

  String name = "Amily";

  @override
  void initState() {
    super.initState();

    bannerHeight = Utils.width * 9.0 / 16.0;

    radius = 45.0;

    padding = 8.0;
  }

  @override
  void dispose() {
    super.dispose();
  }

  List<String> bannerImages = [
    "https://wx2.sinaimg.cn/mw690/66fa6be4gy1fzd1sif9tuj218g0p143d.jpg",
    "https://wx2.sinaimg.cn/mw690/66fa6be4gy1fzd1sif9tuj218g0p143d.jpg",
    "https://wx2.sinaimg.cn/mw690/66fa6be4gy1fzd1sif9tuj218g0p143d.jpg",
    "https://wx2.sinaimg.cn/mw690/66fa6be4gy1fzd1sif9tuj218g0p143d.jpg"
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      body: MediaQuery.removePadding(
          removeTop: true,
          context: context,
          child: ListView(children: <Widget>[
            Stack(
              children: <Widget>[
                Container(
                  height: bannerHeight,
                  child: Swiper(
                    itemCount: 4,
                    autoplay: true,
                    itemBuilder: (_, index) =>
                        ImageLoadView(bannerImages[index]),
                    pagination: SwiperCustomPagination(
                      builder:
                          (BuildContext context, SwiperPluginConfig config) =>
                              Container(
                        alignment: Alignment.bottomRight,
                        child: Container(
                          margin: EdgeInsets.only(bottom: 25, right: padding),
                          padding: EdgeInsets.symmetric(
                              horizontal: padding, vertical: 5),
                          decoration: BoxDecoration(
                            borderRadius: BorderRadius.all(
                              Radius.circular(20),
                            ),
                            color: Color(0xAA423B5F),
                          ),
                          child: Text(
                            '${(config.activeIndex + 1)}/4',
                            style: TextStyle(color: Colors.white, fontSize: 13),
                          ),
                        ),
                      ),
                    ),
                  ),
                ),
                Container(
                  padding: EdgeInsets.only(top: radius + padding + 15),
                  margin: EdgeInsets.only(top: bannerHeight - 15),
                  decoration: const BoxDecoration(
                      borderRadius: const BorderRadius.only(
                        topLeft: Radius.circular(20),
                        topRight: Radius.circular(20),
                      ),
                      color: Colors.white,
                      boxShadow: [
                        BoxShadow(
                          color: Colors.white,
                          blurRadius: 10.0,
                        )
                      ]),
                  width: Utils.width,
                  child: Column(
                    children: [
                      Row(
                        children: <Widget>[
                          Button(
                            child: Text(
                              'CONNECT',
                              style: const TextStyle(
                                  color: Colors.white, fontSize: 12.0),
                            ),
                            width: 110.0,
                            onPressed: () {},
                            height: 30,
                            color: Color(0xFF786FE9),
                            halfRadius: true,
                          ),
                          Button(
                            child: Text(
                              'FOLLOW',
                              style: const TextStyle(
                                  color: Colors.white, fontSize: 12.0),
                            ),
                            width: 110.0,
                            onPressed: () {},
                            height: 28,
                            color: Color(0xFF26A06C),
                            halfRadius: true,
                          ),
                        ],
                        mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                      ),
                      Padding(
                        padding: const EdgeInsets.symmetric(vertical: 20),
                        child: Row(
                          children: <Widget>[
                            Image.asset(
                              'images/femal.png',
                              height: 15,
                            ),
                            SizedBox(width: 8),
                            Text(
                              '',
                              style: const TextStyle(
                                  color: Colors.black,
                                  fontSize: 16,
                                  fontWeight: FontWeight.bold),
                            ),
                            SizedBox(width: 8),
                            GestureDetector(
                              onTap: () {
                                // pushNewPage(
                                //     context,
                                //     InputTextPage(
                                //       title: '修改姓名',
                                //       content: '',
                                //       maxLines: 1,
                                //     ), callBack: (value) {
                                //   setState(() {
                                //     name = value;
                                //   });
                                // });
                              },
                              child: Image.asset(
                                'images/write.png',
                                width: 15,
                                height: 15,
                                color: Color(0xFF606060),
                              ),
                            ),
                          ],
                          mainAxisSize: MainAxisSize.min,
                        ),
                      ),
                      Padding(
                        padding: EdgeInsets.only(bottom: padding),
                        child: Text(
                          'It`s a beatifull day today',
                          style: const TextStyle(
                              fontSize: 12, color: Color(0xFF525252)),
                        ),
                      ),
                      Container(
                        width: 180,
                        height: 40,
                        child: RaisedButton(
                          onPressed: () {
                            NavigatorUtils.push(
                                context, '${MineRouter.collectionPage}');
                          },
                          child: const Text(
                            'Message',
                            style: const TextStyle(color: Color(0xFF63B296)),
                          ),
                          shape: const StadiumBorder(),
                          elevation: 5.0,
                          color: Colors.white,
                        ),
                      ),
                      Container(
                        width: Utils.width,
                        padding:
                            EdgeInsets.symmetric(vertical: 30, horizontal: 20),
                        child: Text(
                          'Information',
                          style: TextStyle(
                            color: Color(0xFF50A479),
                            fontWeight: FontWeight.bold,
                            fontSize: 18,
                          ),
                        ),
                      ),
                      Container(
                        child: Column(
                          children: [
                            Row(
                              children: <Widget>[
                                Expanded(
                                  child: Text(
                                    'Name:',
                                    textAlign: TextAlign.end,
                                    style: TextStyle(
                                        color: Colors.black,
                                        fontWeight: FontWeight.bold,
                                        fontSize: 16),
                                  ),
                                  flex: 1,
                                ),
                                SizedBox(width: 20),
                                Expanded(
                                  child: Text(
                                    'Amily-3562',
                                    textAlign: TextAlign.start,
                                    style: TextStyle(
                                        color: Color(0xFF3D3D3D), fontSize: 14),
                                  ),
                                  flex: 3,
                                ),
                              ],
                            ),
                            SizedBox(height: 10.0),
                            Row(
                              children: <Widget>[
                                Expanded(
                                  child: Text(
                                    'Email:',
                                    textAlign: TextAlign.end,
                                    style: TextStyle(
                                        color: Colors.black,
                                        fontWeight: FontWeight.bold,
                                        fontSize: 16),
                                  ),
                                  flex: 1,
                                ),
                                SizedBox(width: 20),
                                Expanded(
                                  child: Text(
                                    'amily-smiths@gmail.com',
                                    textAlign: TextAlign.start,
                                    style: TextStyle(
                                        color: Color(0xFF3D3D3D), fontSize: 14),
                                  ),
                                  flex: 3,
                                ),
                              ],
                            ),
                            SizedBox(height: 10.0),
                            Row(
                              children: <Widget>[
                                Expanded(
                                  child: Text(
                                    'Region:',
                                    textAlign: TextAlign.end,
                                    style: TextStyle(
                                        color: Colors.black,
                                        fontWeight: FontWeight.bold,
                                        fontSize: 16),
                                  ),
                                  flex: 1,
                                ),
                                SizedBox(width: 20),
                                Expanded(
                                  child: Text(
                                    'Sydney,NSW,Australia',
                                    textAlign: TextAlign.start,
                                    style: TextStyle(
                                        color: Color(0xFF3D3D3D), fontSize: 14),
                                  ),
                                  flex: 3,
                                ),
                              ],
                            ),
                          ],
                        ),
                      )
                    ],
                  ),
                ),
                Positioned(
                  child: CircleAvatar(
                    backgroundImage: NetworkImage(
                        'https://wx2.sinaimg.cn/mw690/66fa6be4gy1fzd1sif9tuj218g0p143d.jpg'),
                    radius: radius,
                  ),
                  top: bannerHeight - radius - 15,
                  left: Utils.width / 2 - radius,
                  right: Utils.width / 2 - radius,
                ),
                Positioned(
                  child: Text(
                    'ID:234390',
                    style: TextStyle(fontSize: 18),
                  ),
                  left: Utils.width / 2.0 + radius + padding,
                  right: padding,
                  top: bannerHeight,
                ),
                Container(
                  child: AppBar(
                    elevation: 0.0,
                    backgroundColor: Color.fromRGBO(34, 45, 56, 0.0),
                    actions: <Widget>[
                      IconButton(
                          icon: Icon(
                            Icons.more_vert,
                          ),
                          onPressed: () {})
                    ],
                  ),
                  height: Utils.navigationBarHeight + Utils.topSafeHeight,
                ),
              ],
            )
          ])),
    );
  }
}
